package com.hdl.servlet.admin;

import java.io.IOException;
import java.util.UUID;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hdl.entity.MallProduct;
import com.hdl.service.MallProductService;
import com.hdl.service.impl.MallProductServiceImpl;
import com.hdl.util.SysUtil;
import com.hdl.util.UploadLogUtil;


@WebServlet("/admin/mallproduct-add.let")
public class MallProductAddServlet extends HttpServlet{
	private MallProductService m = new MallProductServiceImpl();
	   @Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		   request.setCharacterEncoding("utf-8");
		   
		   MallProduct product = new MallProduct();
		   
		   //封装属性
		   UploadLogUtil.uploadProduct(request, response, product);
		   
		   
		   String id = SysUtil.get();
		   product.setMallProductId(id);

		   m.AddProduct(product);
		   
		  response.sendRedirect(request.getContextPath()+"/admin/mall-list.let");
		   
	}
	   
	   @Override
		protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			doGet(req, resp);
		}
}
